home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / c / appsource.lha / APlusPlus / libsource / ObjectList.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  1.6 KB  |  69 lines

  1. /******************************************************************************
  2.  **
  3.  **   C++ Class Library for the Amiga© system software.
  4.  **
  5.  **   Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **   All Rights Reserved.
  7.  **
  8.  **   $Source: apphome:RCS/libsource/ObjectList.cxx,v $
  9.  **   $Revision: 1.7 $
  10.  **   $Date: 1994/07/27 11:51:16 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <APlusPlus/exec/ObjectList.h>
  17. #include <APlusPlus/environment/APPObject.h>
  18.  
  19.  
  20. static const char rcs_id[] = "$Id: ObjectList.cxx,v 1.7 1994/07/27 11:51:16 Armin_Vogt Exp Armin_Vogt $";
  21.  
  22.  
  23. ReferenceNode::ReferenceNode(APTR object, UBYTE type) : PriorityNode((UBYTE*)object,type)
  24. {
  25. }
  26.  
  27. ReferenceList::ReferenceList(UBYTE type) : PriorityList(type)
  28. {
  29. }
  30.  
  31. TObjNode::TObjNode(APTR object, UBYTE type) : ReferenceNode(object,type)
  32. {
  33. }
  34.  
  35. TObjList::TObjList(UBYTE type) : ReferenceList(type)
  36. {
  37. }
  38.  
  39. TObjList::~TObjList()
  40.    /* Delete all traced objects at the end of the programm.
  41.    */
  42. {
  43.    FOREACHSAFE(TObjNode, this)
  44.    {
  45.       delete node;
  46.    }
  47.    NEXTSAFE
  48.    _dprintf("~TObjList done\n");
  49. }
  50.  
  51. ReferenceNode *ReferenceList::findObject(APTR objectptr,UBYTE objtype)
  52. {
  53.    FOREACHOF(ReferenceNode,this)
  54.       if (objectptr==NULL || node->object() == objectptr)
  55.          if (objtype==0 || node->type() == objtype) return node;
  56.  
  57.    return NULL;
  58. }
  59.  
  60. void TObjList::deleteTObj(APTR obj)
  61. {
  62.    TObjNode *node;
  63.  
  64.    if (node = (TObjNode*)findObject(obj))
  65.    {
  66.       delete node;   // remove node, free resource and free memory
  67.    }
  68. }
  69.